package classinteger;

public class IntegerDemo {
    public static void main(String[] args) {
        //将包装类转为基本类型
        Integer i = new Integer(10);
        int a = Integer.valueOf(10);

        //将引用数据类型转为基本类型
        String s = "123";
        System.out.println("s = " + s);
        //调用Integer静态方法parseInt
        int b = Integer.parseInt(s);
        b += 1;
        System.out.println("b+1  = " + b);
        System.out.println("b+1  = " + (b+1));

        //自动装箱
        int a1 = 10;
        Integer n = a1;

        //自动拆箱
        Integer num1 = 127;
        Integer num2 = 127;
        Integer num3 = 128;
        Integer num4 = 128;

        System.out.println(num1==num2);
        System.out.println(num3==num4);

        //空指针异常
        Integer a2 = null;
        System.out.println("a2 = " + a2);
        int a3 = a2;
    }
}
